<template>
  <!--名单剔除日志-->
  <section class="page role-manage">
    <data-form :model="roleModel" :rules="rules" @onSearch="refreshData" :page="pageService">
      <template slot="inputs">
        <el-form-item label="账户号" prop="caseNumber">
          <el-input v-model="roleModel.caseNumber"></el-input>
        </el-form-item>
        <el-form-item label="客户号" prop="personalNo">
          <el-input v-model="roleModel.personalNo" ></el-input>
        </el-form-item>
        <el-form-item label="客户姓名" prop="personalName">
          <el-input v-model="roleModel.personalName" :maxlength="20"></el-input>
        </el-form-item>
        <el-form-item label="证件号" prop="idNumber">
          <el-input v-model="roleModel.idNumber" :maxlength="18"></el-input>
        </el-form-item>
        <el-form-item label="账户总金额" prop="caseMoney">
          <number-range v-model="roleModel.caseMoney"></number-range>
        </el-form-item>
        <el-form-item label="账户逾期总金额" class="widthOne" prop="overdueAmount">
          <number-range v-model="roleModel.overdueAmount"></number-range>
        </el-form-item>
        <el-form-item label="逾期期数" prop="overduePeriod">
          <number-range v-model="roleModel.overduePeriod"></number-range>
        </el-form-item>
        <el-form-item label="逾期天数" prop="overdueDays">
          <number-range v-model="roleModel.overdueDays"></number-range>
        </el-form-item>
        <el-form-item label="还款日" prop="payDate">
          <!-- <el-date-picker type="daterange" :editable="false" v-model="roleModel.payDate" placeholder="选择日期时间" clearable /> -->
          <number-range v-model="roleModel.payDate"></number-range>
          <!-- <el-input type="number" v-model="roleModel.payDate"></el-input> -->
        </el-form-item>
        <el-form-item label="账单日" prop="billDate">
          <!-- <el-date-picker type="daterange" :editable="false" v-model="roleModel.billDate" placeholder="选择日期时间" clearable /> -->
          <number-range v-model="roleModel.billDate"></number-range>
          <!-- <el-input type="number" v-model="roleModel.billDate"></el-input> -->
        </el-form-item>
        <el-form-item label="手机号" prop="mobileNo">
          <el-input v-model="roleModel.mobileNo" :maxlength="11"></el-input>
        </el-form-item>
        <el-form-item label="产品编号" prop="productNo">
          <el-input v-model="roleModel.productNo" :maxlength="20"></el-input>
        </el-form-item>

        <el-form-item label="剔除渠道" prop="eliminateChannel">
          <el-select v-model="roleModel.eliminateChannel" placeholder="请选择" clearable>
            <el-option v-for="{index,name,code} in $dict.getDictData('ChannelType')" :key="index" :label="name" :value="code">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="剔除类型" align="left" prop="strategyEliminateType">
          <el-select v-model="roleModel.strategyEliminateType">
            <el-option v-for="{ index, name, code } in $dict.getDictData(
                  'StrategyEliminateType'
                )" :key="index" :label="name" :value="code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="队列代码" prop="queueCode">
          <el-input v-model="roleModel.queueCode" :maxlength="20"></el-input>
        </el-form-item>
        <el-form-item label="AT" prop="at">
          <el-input v-model="roleModel.at" :maxlength="20"></el-input>
        </el-form-item>
        <el-form-item label="CT" prop="ct">
          <el-input v-model="roleModel.ct" :maxlength="20"></el-input>
        </el-form-item>
        <el-form-item label="入催原因码" prop="reasonCode">
          <el-select v-model="roleModel.reasonCode" placeholder="请选择" clearable>
            <el-option v-for="{ index, name, code } in $dict.getDictData('ReasonCode')" :key="index" :label="name" :value="code"></el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="生效时间" prop="effectiveDate">
          <el-date-picker v-model="roleModel.effectiveDate" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
        <el-form-item label="失效时间" prop="expirationDate">
          <el-date-picker v-model="roleModel.expirationDate" type="date" placeholder="选择日期">
          </el-date-picker>
        </el-form-item>
      </template>
    </data-form>

    <data-box :data="roleDataSet" @onPageChange="refreshData" :page="pageService">
      <template slot="columns">
        <!--数据列区域-->
        <el-table-column prop="caseNumber" label="账户号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="personalNo" label="客户号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="personalName" label="客户姓名" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="idNumber" label="证件号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="mobileNo" label="手机号" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="productNo" label="产品编号" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="overduePeriod" label="逾期期数" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="overdueDays" label="逾期天数" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="caseMoney" label="账户总金额" :min-width="$helper.getColumnWidth(4)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="overdueAmount" label="账户逾期总金额" :min-width="$helper.getColumnWidth(5)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="reasonCode" label="入催原因码" :min-width="$helper.getColumnWidth(4)" :formatter="row => $filter.dictConvert(row.reasonCode, 'ReasonCode')" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="queueCode" label="队列代码" :min-width="$helper.getColumnWidth(4)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="eliminateChannel" label="剔除渠道" :formatter="(row) => $filter.dictConvert(row.eliminateChannel,'ChannelType')" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="strategyEliminateType" label="剔除类型" :formatter="(row) => $filter.dictConvert(row.strategyEliminateType,'StrategyEliminateType')" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <!-- <el-table-column prop="payDate" label="还款日" :formatter="row => $filter.dateFormat(row.payDate)" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column prop="billDate" label="账单日" :formatter="row => $filter.dateFormat(row.billDate)" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column> -->
        <el-table-column prop="payDate" label="还款日" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip sortable>
        </el-table-column>
        <el-table-column prop="billDate" label="账单日" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip sortable>
        </el-table-column>
        <el-table-column prop="effectiveDate" label="生效时间" :formatter="row => $filter.dateFormat(row.effectiveDate)" :min-width="$helper.getColumnWidth(3)" show-overflow-tooltip>
        </el-table-column>
        <el-table-column label="失效时间" prop="expirationDate" :formatter="row => $filter.dateFormat(row.expirationDate)" :min-width="$helper.getColumnWidth(3)">
        </el-table-column>
      </template>
    </data-box>
    <div class="operate-buttons">
      <el-button @click="close">关闭</el-button>
    </div>
  </section>
</template>

<script lang="ts">
import Vue from "vue";
import Component from "vue-class-component";
import { Layout, Dependencies } from "~/core/decorator";
import { EliminateStrateguLogService } from "~/services/domain-service/eliminate-strategy-log.service"
import { ListRemovedService } from "~/services/domain-service/list-removed.service"
import { Emit, Prop } from "vue-property-decorator";
import { PageService } from "~/utils/page.service";
import { namespace, State } from "vuex-class";
import NumberRange from "~/components/common/number-range.vue";

const systemModule = namespace("system-manage");


@Layout("workspace")
@Component({
  components: {
    NumberRange
  }
})
export default class ListRemoved extends Vue {
  @Dependencies(EliminateStrateguLogService)
  private eliminateStrateguLogService: EliminateStrateguLogService;
  @Dependencies(ListRemovedService)
  private listRemovedService: ListRemovedService;
  @Dependencies(PageService)
  private pageService: PageService;
  @systemModule.Action private updateResource: () => void;

  @State private principalList: any
  private roleModel: any = {
    id: '',
    caseNumber: '',
    personalNo: '',
    personalName: '',
    idNumber: '',
    caseMoney: '',
    overdueAmount: '',
    overduePeriod: '',
    overdueDays: '',
    payDate: { max: "", min: "" },
    billDate: { max: "", min: "" },
    mobileNo: '',
    productNo: '',
    eliminateChannel: '',
    eliminateType: '',
    queueCode: '',
    at: '',
    ct: '',
    reasonCode: '',
    effectiveDate: '',
    expirationDate: '',
  };
  
  @Prop() private roleData;
  private roleDataSet: any[] = [];

  @Emit("close")
  public close() { }
  /**
   * 日志详情
   */
  public refreshData() {
    if (this.roleModel.caseNumber && this.$validator.regex.isChineseComma.test(this.roleModel.caseNumber)) return this.$message.error("请用英文逗号！");
    this.roleModel.id = this.roleData.id
    this.eliminateStrateguLogService.queryRecord(this.paramsHandler(), this.pageService).subscribe(data => {
      this.roleDataSet = data;
    })
  }

  private mounted() {
    this.refreshData();
    this.updateResource();
  }
  private follFeedback () {
    this.roleModel.payDate = { min: "", max: "" };
    this.roleModel.billDate = { min: "", max: "" };
  }
  private paramsHandler() {
    const params = { ...this.roleModel };
    // params.payDateMax = this.$filter.dateRanageFormat(this.roleModel.payDate).end;
    // params.payDateMin = this.$filter.dateRanageFormat(this.roleModel.payDate).start;
    // params.billDateMax = this.$filter.dateRanageFormat(this.roleModel.billDate).end;
    // params.billDateMin = this.$filter.dateRanageFormat(this.roleModel.billDate).start;
    params.payDateMax = this.roleModel.payDate.max;
    params.payDateMin = this.roleModel.payDate.min;
    params.billDateMax = this.roleModel.billDate.max;
    params.billDateMin = this.roleModel.billDate.min;
    delete params.billDate;
    delete params.payDate;
    return params;
  }
}
</script>

<style lang="less">
.widthOne > .el-form-item__label {
  width: 96px !important;
}
</style>
